/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.st.entity;

import org.hibernate.validator.constraints.Length;

import java.util.Date;

import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.List;

import com.jeesite.common.collect.ListUtils;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 生产工单Entity
 *
 * @author HOHD
 * @version 2020-12-19
 */
@Table(name = "st_product_bill", alias = "a", columns = {
        @Column(name = "id", attrName = "id", label = "id", isPK = true),
        @Column(name = "bill_no", attrName = "billNo", label = "单据号"),
        @Column(name = "bill_date", attrName = "billDate", label = "单据日期"),
        @Column(name = "has_product_number", attrName = "hasProductNumber", label = "已生产数量"),
        @Column(name = "research", attrName = "research", label = "是否研发"),
        @Column(name = "bill_status", attrName = "billStatus", label = "工单状态"),
        @Column(name = "plain_complete_date", attrName = "plainCompleteDate", label = "计划完成日期"),
        @Column(name = "make_request", attrName = "makeRequest", label = "制作要求"),
        @Column(name = "product_name", attrName = "productName", label = "产品名称", queryType = QueryType.LIKE),
        @Column(name = "this_formula", attrName = "thisFormula", label = "本次配方"),
        @Column(name = "bill_type", attrName = "billType", label = "工单类别"),
        @Column(name = "bill_number", attrName = "billNumber", label = "工单数量"),
        @Column(name = "per_weight", attrName = "perWeight", label = "每批重量"),
        @Column(name = "product_batch", attrName = "productBatch", label = "生产批次"),
        @Column(name = "tailing_material_upper_limit", attrName = "tailingMaterialUpperLimit", label = "尾料上限"),
        @Column(name = "tailing_material_lower_limit", attrName = "tailingMaterialLowerLimit", label = "尾料下限"),
        @Column(name = "prepare_mix_carrier", attrName = "prepareMixCarrier", label = "预混载体"),
        @Column(name = "prepare_mix_weight", attrName = "prepareMixWeight", label = "预混桶重量"),
        @Column(name = "back_material_name", attrName = "backMaterialName", label = "回机料名称", queryType = QueryType.LIKE),
        @Column(name = "back_material_weight", attrName = "backMaterialWeight", label = "回机料重量"),
        @Column(name = "approve_state", attrName = "approveState", label = "审批状态"),
        @Column(name = "update_date", attrName = "updateDate", label = "更新时间", isQuery = false),
        @Column(name = "approve_man_code", attrName = "approveManCode", label = "审批人编码"),
        @Column(name = "approve_man_name", attrName = "approveManName", label = "审批人", queryType = QueryType.LIKE),
}, orderBy = "a.id DESC", joinTable = {
        // 原来是join啊
        @JoinTable(on = "pr.id=a.product_name", entity = StProductRecord.class, attrName = "product", alias = "pr", type = Type.LEFT_JOIN),
        @JoinTable(on = "f.id=a.this_formula", entity = StFormulaName.class, alias = "f", attrName = "formula", type = Type.LEFT_JOIN),
        @JoinTable(on = "mix.id=a.prepare_mix_carrier", entity = StMaterialRecord.class, alias = "mix", attrName = "mix", type = Type.LEFT_JOIN),
        @JoinTable(on = "back.id=a.back_material_name", entity = StMaterialRecord.class, alias = "back", attrName = "back", type = Type.LEFT_JOIN),
}
)
public class StProductBill extends DataEntity<StProductBill> {

    private static final long serialVersionUID = 1L;
    private String billNo;        // 单据号
    private Date billDate;        // 单据日期
    private Integer hasProductNumber;        // 已生产数量
    private Integer research;        // 是否研发
    private Integer billStatus;        // 工单状态
    private Date plainCompleteDate;        // 计划完成日期
    private String makeRequest;        // 制作要求
    private String productName;        // 产品名称,可能是id，也可能是name
    private StProductRecord product;        // 产品名称,可能是id，也可能是name
    private String productCode;        //
    private String thisFormula;        // 本次配方
    private StFormulaName formula;        // 本次配方
    private Integer billType;        // 工单类别
    private Integer billNumber;        // 工单数量
    private Integer perWeight;        // 每批重量
    private Integer productBatch;        // 生产批次
    private Integer tailingMaterialUpperLimit;        // 尾料上限
    private Integer tailingMaterialLowerLimit;        // 尾料下限
    private String prepareMixCarrier;        // 预混载体
    private StMaterialRecord mix;        // 预混载体
    private Integer prepareMixWeight;        // 预混桶重量
    private String backMaterialName;        // 回机料名称
    private StMaterialRecord back;        // 回机料名称

    private Integer backMaterialWeight;        // 回机料重量
    private Integer approveState;        // 审批状态
    private String approveManCode;        // 审批人编码
    private String approveManName;        // 审批人
    private List<StProductBillBatchDetail> stProductBillBatchDetailList = ListUtils.newArrayList();        // 子表列表
    private List<StProductBillDetail> stProductBillDetailList = ListUtils.newArrayList();        // 子表列表

    public StProductBill() {
        this(null);
    }

    public void inIds(String ids) {
        if (ids.endsWith(",")) ids = ids.substring(0, ids.length() - 1);
        ids = "(" + ids + ")";
        sqlMap.getWhere().and("id", QueryType.IN, ids);
    }

    public String getProductCode() {
        return productCode;
    }

    public StMaterialRecord getMix() {
        return mix;
    }

    public void setMix(StMaterialRecord mix) {
        this.mix = mix;
    }

    public StMaterialRecord getBack() {
        return back;
    }

    public void setBack(StMaterialRecord back) {
        this.back = back;
    }

    public StFormulaName getFormula() {
        return formula;
    }

    public void setFormula(StFormulaName formula) {
        this.formula = formula;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    public StProductRecord getProduct() {
        return product;
    }

    public void setProduct(StProductRecord product) {
        this.product = product;
    }

    public StProductBill(String id) {
        super(id);
    }

    @Length(min = 0, max = 20, message = "单据号长度不能超过 20 个字符")
    public String getBillNo() {
        return billNo;
    }

    public void setBillNo(String billNo) {
        this.billNo = billNo;
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public Date getBillDate() {
        return billDate;
    }

    public void setBillDate(Date billDate) {
        this.billDate = billDate;
    }

    public Integer getHasProductNumber() {
        return hasProductNumber;
    }

    public void setHasProductNumber(Integer hasProductNumber) {
        this.hasProductNumber = hasProductNumber;
    }

    public Integer getResearch() {
        return research;
    }

    public void setResearch(Integer research) {
        this.research = research;
    }

    public Integer getBillStatus() {
        return billStatus;
    }

    public void setBillStatus(Integer billStatus) {
        this.billStatus = billStatus;
    }

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public Date getPlainCompleteDate() {
        return plainCompleteDate;
    }

    public void setPlainCompleteDate(Date plainCompleteDate) {
        this.plainCompleteDate = plainCompleteDate;
    }

    @Length(min = 0, max = 20, message = "制作要求长度不能超过 20 个字符")
    public String getMakeRequest() {
        return makeRequest;
    }

    public void setMakeRequest(String makeRequest) {
        this.makeRequest = makeRequest;
    }

    @Length(min = 0, max = 36, message = "产品名称长度不能超过 36 个字符")
    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    @Length(min = 0, max = 36, message = "本次配方长度不能超过 36 个字符")
    public String getThisFormula() {
        return thisFormula;
    }

    public void setThisFormula(String thisFormula) {
        this.thisFormula = thisFormula;
    }

    public Integer getBillType() {
        return billType;
    }

    public void setBillType(Integer billType) {
        this.billType = billType;
    }

    public Integer getBillNumber() {
        return billNumber;
    }

    public void setBillNumber(Integer billNumber) {
        this.billNumber = billNumber;
    }

    public Integer getPerWeight() {
        return perWeight;
    }

    public void setPerWeight(Integer perWeight) {
        this.perWeight = perWeight;
    }

    public Integer getProductBatch() {
        return productBatch;
    }

    public void setProductBatch(Integer productBatch) {
        this.productBatch = productBatch;
    }

    public Integer getTailingMaterialUpperLimit() {
        return tailingMaterialUpperLimit;
    }

    public void setTailingMaterialUpperLimit(Integer tailingMaterialUpperLimit) {
        this.tailingMaterialUpperLimit = tailingMaterialUpperLimit;
    }

    public Integer getTailingMaterialLowerLimit() {
        return tailingMaterialLowerLimit;
    }

    public void setTailingMaterialLowerLimit(Integer tailingMaterialLowerLimit) {
        this.tailingMaterialLowerLimit = tailingMaterialLowerLimit;
    }

    @Length(min = 0, max = 36, message = "预混载体长度不能超过 36 个字符")
    public String getPrepareMixCarrier() {
        return prepareMixCarrier;
    }

    public void setPrepareMixCarrier(String prepareMixCarrier) {
        this.prepareMixCarrier = prepareMixCarrier;
    }

    public Integer getPrepareMixWeight() {
        return prepareMixWeight;
    }

    public void setPrepareMixWeight(Integer prepareMixWeight) {
        this.prepareMixWeight = prepareMixWeight;
    }

    @Length(min = 0, max = 36, message = "回机料名称长度不能超过 36 个字符")
    public String getBackMaterialName() {
        return backMaterialName;
    }

    public void setBackMaterialName(String backMaterialName) {
        this.backMaterialName = backMaterialName;
    }

    public Integer getBackMaterialWeight() {
        return backMaterialWeight;
    }

    public void setBackMaterialWeight(Integer backMaterialWeight) {
        this.backMaterialWeight = backMaterialWeight;
    }

    public Integer getApproveState() {
        return approveState;
    }

    public void setApproveState(Integer approveState) {
        this.approveState = approveState;
    }

    @Length(min = 0, max = 20, message = "审批人编码长度不能超过 20 个字符")
    public String getApproveManCode() {
        return approveManCode;
    }

    public void setApproveManCode(String approveManCode) {
        this.approveManCode = approveManCode;
    }

    @Length(min = 0, max = 5, message = "审批人长度不能超过 5 个字符")
    public String getApproveManName() {
        return approveManName;
    }

    public void setApproveManName(String approveManName) {
        this.approveManName = approveManName;
    }

    public List<StProductBillBatchDetail> getStProductBillBatchDetailList() {
        return stProductBillBatchDetailList;
    }

    public void setStProductBillBatchDetailList(List<StProductBillBatchDetail> stProductBillBatchDetailList) {
        this.stProductBillBatchDetailList = stProductBillBatchDetailList;
    }

    public List<StProductBillDetail> getStProductBillDetailList() {
        return stProductBillDetailList;
    }

    public void setStProductBillDetailList(List<StProductBillDetail> stProductBillDetailList) {
        this.stProductBillDetailList = stProductBillDetailList;
    }

}